﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Subgurim.Controles;

public partial class all_incidents : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void current_active_databound(object sender, EventArgs e)
    {
        populate_Maps_Active();
    }

    protected void resolved_databound(object sender, EventArgs e)
    {
        populate_Maps_Resolved();
    }



    protected void populate_Maps_Active()
    {

        int value = current_Active_GV.Rows.Count;
        while (value > 0)
        {
            value = value - 1;

            //string lm = ((Label)public_Lv.Items[value].FindControl("Landmarklabel")).Text;
            string lm = current_Active_GV.Rows[value].Cells[3].Text;
            string state = current_Active_GV.Rows[value].Cells[5].Text;
            string city = current_Active_GV.Rows[value].Cells[4].Text;
            string type = current_Active_GV.Rows[value].Cells[2].Text;
            string status = current_Active_GV.Rows[value].Cells[0].Text;    
            string fullAddr = lm + ", " + city + ", " + state; //combines all the locations to give to the geocode requester.

            //Basics of the Map. 
            GMap.Add(new GControl(GControl.preBuilt.LargeMapControl));
            GeoCode geographycode = GMap.geoCodeRequest(fullAddr);
            GLatLng gLngLat = new GLatLng(geographycode.Placemark.coordinates.lat, geographycode.Placemark.coordinates.lng);

            GeoCode australia_geocode = GMap.geoCodeRequest("Australia");
            GLatLng aus_gLngLat = new GLatLng(australia_geocode.Placemark.coordinates.lat, australia_geocode.Placemark.coordinates.lng);

            GMap.setCenter(aus_gLngLat, 3); // Sets the center of the Map.

            GMarker lm_marker = new GMarker(gLngLat);
            GMap.addGMarker(lm_marker);

            //This part is for the Info Window
            GInfoWindow window = new GInfoWindow(lm_marker, "Status: " + status + "<br/> Type: " + type + "<br/> Location: " + lm + ", " + city + ", " + state);
            GMap.addInfoWindow(window);
        }
    }

    protected void populate_Maps_Resolved()
    {

        int value = resolved_GV.Rows.Count;
        while (value > 0)
        {
            value = value - 1;

            //string lm = ((Label)public_Lv.Items[value].FindControl("Landmarklabel")).Text;
            string lm = resolved_GV.Rows[value].Cells[3].Text;
            string state = resolved_GV.Rows[value].Cells[5].Text;
            string city = resolved_GV.Rows[value].Cells[4].Text;
            string type = resolved_GV.Rows[value].Cells[2].Text;
            string status = resolved_GV.Rows[value].Cells[0].Text;
            string fullAddr = lm + ", " + city + ", " + state; //combines all the locations to give to the geocode requester.

            //Basics of the Map. 
            GeoCode geographycode = GMap.geoCodeRequest(fullAddr);
            GLatLng gLngLat = new GLatLng(geographycode.Placemark.coordinates.lat, geographycode.Placemark.coordinates.lng);

            GeoCode australia_geocode = GMap.geoCodeRequest("Australia");
            GLatLng aus_gLngLat = new GLatLng(australia_geocode.Placemark.coordinates.lat, australia_geocode.Placemark.coordinates.lng);

            GMap.setCenter(aus_gLngLat, 3); // Sets the center of the Map.

            GMarker lm_marker = new GMarker(gLngLat);
            GMap.addGMarker(lm_marker);

            //This part is for the Info Window
            GInfoWindow window = new GInfoWindow(lm_marker, "Status: " + status + "<br/> Type: " + type + "<br/> Location: " + lm + ", " + city + ", " + state);
            GMap.addInfoWindow(window);
        }
    }

}